//@author A0102103L
//Manages the interaction between user and LazyManCalendar.   
//Receives commands from the user and displays the appropriate feedback.
//UI is only dependent on the Logic component.
//Once user input is received, UI passes it to Logic and Logic handles the rest. La
//LazyManCalendar UI as the name suggest is designed to be simple, small & handy for users

#pragma once

#include <msclr\marshal_cppstd.h>
#include "Logic.h"
#include "Task.h"

namespace UI {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
	using namespace msclr::interop;

	/// <summary>
	/// Summary for LazyManCalendar
	/// </summary>
	public ref class LazyManCalendar : public System::Windows::Forms::Form {
	
	private: Logic * schedule;
	private: Point mouseOffSet; 
	private: static int xOffSet;
	private: static int yOffSet;
	private: System::Windows::Forms::DataGridView^  table;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  No;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  Deadline;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  Time;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  Priority;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  Taskname;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  Status;
	private: System::Windows::Forms::Button^  exitButton;
	private: System::Windows::Forms::Label^  labelLazyManCalendar;
	private: System::Windows::Forms::Button^  minimiseButton;
	private: System::Windows::Forms::Label^  displayDateTime;
	private: System::Windows::Forms::Timer^  timer;
	private: System::Windows::Forms::TextBox^  warningBar;
	private: System::Windows::Forms::PictureBox^  iconPictureBox;
	private: System::Windows::Forms::MonthCalendar^  monthCalendar;
	private: System::Windows::Forms::Panel^  statusPanel;
	private: System::Windows::Forms::PictureBox^  tickPictureBox;
	private: System::Windows::Forms::PictureBox^  crossPictureBox;
	private: System::Windows::Forms::TextBox^  statusBar;

	public:
		LazyManCalendar(void)
		{
			InitializeComponent();
			// 
			//start the dateTime running dynamically
			//
			timer->Start();
			//
			//TODO: Add the constructor code here
			//
			schedule = new Logic();
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~LazyManCalendar()
		{
			if (components) {
				delete components;
				delete schedule;
			}
		}

	protected: 
	private: System::Windows::Forms::TextBox^  inputBox;
	private: System::Windows::Forms::Button^  helpButton;
	private: System::Windows::Forms::TextBox^  lastCommandBar;
	private: System::ComponentModel::IContainer^  components;
			 
	protected: 

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->components = (gcnew System::ComponentModel::Container());
			System::Windows::Forms::DataGridViewCellStyle^  dataGridViewCellStyle12 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
			System::Windows::Forms::DataGridViewCellStyle^  dataGridViewCellStyle7 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
			System::Windows::Forms::DataGridViewCellStyle^  dataGridViewCellStyle8 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
			System::Windows::Forms::DataGridViewCellStyle^  dataGridViewCellStyle9 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
			System::Windows::Forms::DataGridViewCellStyle^  dataGridViewCellStyle10 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
			System::Windows::Forms::DataGridViewCellStyle^  dataGridViewCellStyle11 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(LazyManCalendar::typeid));
			this->inputBox = (gcnew System::Windows::Forms::TextBox());
			this->helpButton = (gcnew System::Windows::Forms::Button());
			this->lastCommandBar = (gcnew System::Windows::Forms::TextBox());
			this->table = (gcnew System::Windows::Forms::DataGridView());
			this->No = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			this->Deadline = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			this->Time = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			this->Priority = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			this->Taskname = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			this->Status = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			this->exitButton = (gcnew System::Windows::Forms::Button());
			this->warningBar = (gcnew System::Windows::Forms::TextBox());
			this->labelLazyManCalendar = (gcnew System::Windows::Forms::Label());
			this->minimiseButton = (gcnew System::Windows::Forms::Button());
			this->displayDateTime = (gcnew System::Windows::Forms::Label());
			this->timer = (gcnew System::Windows::Forms::Timer(this->components));
			this->statusBar = (gcnew System::Windows::Forms::TextBox());
			this->iconPictureBox = (gcnew System::Windows::Forms::PictureBox());
			this->monthCalendar = (gcnew System::Windows::Forms::MonthCalendar());
			this->statusPanel = (gcnew System::Windows::Forms::Panel());
			this->crossPictureBox = (gcnew System::Windows::Forms::PictureBox());
			this->tickPictureBox = (gcnew System::Windows::Forms::PictureBox());
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->table))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->iconPictureBox))->BeginInit();
			this->statusPanel->SuspendLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->crossPictureBox))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->tickPictureBox))->BeginInit();
			this->SuspendLayout();
			// 
			// inputBox
			// 
			this->inputBox->AutoCompleteCustomSource->AddRange(gcnew cli::array< System::String^  >(13) {L"add", L"delete", L"reset", 
				L"undo", L"redo", L"display", L"mark", L"sort", L"exit", L"filter", L"modify", L"reminder", L"search"});
			this->inputBox->AutoCompleteMode = System::Windows::Forms::AutoCompleteMode::SuggestAppend;
			this->inputBox->AutoCompleteSource = System::Windows::Forms::AutoCompleteSource::CustomSource;
			this->inputBox->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->inputBox->Location = System::Drawing::Point(12, 429);
			this->inputBox->Margin = System::Windows::Forms::Padding(6, 6, 6, 6);
			this->inputBox->Name = L"inputBox";
			this->inputBox->Size = System::Drawing::Size(884, 37);
			this->inputBox->TabIndex = 0;
			this->inputBox->PreviewKeyDown += gcnew System::Windows::Forms::PreviewKeyDownEventHandler(this, &LazyManCalendar::inputBox_PreviewKeyDown);
			// 
			// helpButton
			// 
			this->helpButton->BackColor = System::Drawing::SystemColors::Window;
			this->helpButton->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 7.916231F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->helpButton->Location = System::Drawing::Point(1034, 12);
			this->helpButton->Margin = System::Windows::Forms::Padding(6, 6, 6, 6);
			this->helpButton->Name = L"helpButton";
			this->helpButton->Size = System::Drawing::Size(116, 42);
			this->helpButton->TabIndex = 2;
			this->helpButton->TabStop = false;
			this->helpButton->Text = L"F1 Help";
			this->helpButton->UseVisualStyleBackColor = false;
			this->helpButton->Click += gcnew System::EventHandler(this, &LazyManCalendar::helpButton_Click);
			this->helpButton->Enter += gcnew System::EventHandler(this, &LazyManCalendar::helpButton_Enter);
			// 
			// lastCommandBar
			// 
			this->lastCommandBar->BackColor = System::Drawing::SystemColors::Window;
			this->lastCommandBar->BorderStyle = System::Windows::Forms::BorderStyle::None;
			this->lastCommandBar->Location = System::Drawing::Point(12, 388);
			this->lastCommandBar->Margin = System::Windows::Forms::Padding(6, 6, 6, 6);
			this->lastCommandBar->Multiline = true;
			this->lastCommandBar->Name = L"lastCommandBar";
			this->lastCommandBar->Size = System::Drawing::Size(712, 35);
			this->lastCommandBar->TabIndex = 5;
			this->lastCommandBar->TabStop = false;
			this->lastCommandBar->Text = L"Last command will be here";
			this->lastCommandBar->Enter += gcnew System::EventHandler(this, &LazyManCalendar::lastCommandBar_Enter);
			// 
			// table
			// 
			this->table->AllowUserToAddRows = false;
			this->table->AllowUserToDeleteRows = false;
			this->table->AutoSizeColumnsMode = System::Windows::Forms::DataGridViewAutoSizeColumnsMode::AllCells;
			this->table->BackgroundColor = System::Drawing::SystemColors::Window;
			this->table->BorderStyle = System::Windows::Forms::BorderStyle::None;
			this->table->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
			this->table->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^  >(6) {this->No, this->Deadline, 
				this->Time, this->Priority, this->Taskname, this->Status});
			dataGridViewCellStyle12->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleLeft;
			dataGridViewCellStyle12->BackColor = System::Drawing::SystemColors::Window;
			dataGridViewCellStyle12->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 7.916231F, System::Drawing::FontStyle::Regular, 
				System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
			dataGridViewCellStyle12->ForeColor = System::Drawing::SystemColors::ControlText;
			dataGridViewCellStyle12->SelectionBackColor = System::Drawing::Color::White;
			dataGridViewCellStyle12->SelectionForeColor = System::Drawing::SystemColors::ControlText;
			dataGridViewCellStyle12->WrapMode = System::Windows::Forms::DataGridViewTriState::False;
			this->table->DefaultCellStyle = dataGridViewCellStyle12;
			this->table->Location = System::Drawing::Point(12, 88);
			this->table->Margin = System::Windows::Forms::Padding(6, 6, 6, 6);
			this->table->MultiSelect = false;
			this->table->Name = L"table";
			this->table->ReadOnly = true;
			this->table->RowHeadersVisible = false;
			this->table->RowHeadersWidthSizeMode = System::Windows::Forms::DataGridViewRowHeadersWidthSizeMode::AutoSizeToDisplayedHeaders;
			this->table->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
			this->table->ShowCellToolTips = false;
			this->table->ShowEditingIcon = false;
			this->table->Size = System::Drawing::Size(884, 290);
			this->table->TabIndex = 6;
			this->table->PreviewKeyDown += gcnew System::Windows::Forms::PreviewKeyDownEventHandler(this, &LazyManCalendar::table_PreviewKeyDown);
			// 
			// No
			// 
			this->No->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::None;
			dataGridViewCellStyle7->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter;
			this->No->DefaultCellStyle = dataGridViewCellStyle7;
			this->No->HeaderText = L"No";
			this->No->Name = L"No";
			this->No->ReadOnly = true;
			this->No->Resizable = System::Windows::Forms::DataGridViewTriState::True;
			this->No->Width = 30;
			// 
			// Deadline
			// 
			this->Deadline->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::None;
			dataGridViewCellStyle8->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter;
			this->Deadline->DefaultCellStyle = dataGridViewCellStyle8;
			this->Deadline->HeaderText = L"Deadline";
			this->Deadline->Name = L"Deadline";
			this->Deadline->ReadOnly = true;
			this->Deadline->Width = 55;
			// 
			// Time
			// 
			dataGridViewCellStyle9->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter;
			this->Time->DefaultCellStyle = dataGridViewCellStyle9;
			this->Time->HeaderText = L"Time";
			this->Time->Name = L"Time";
			this->Time->ReadOnly = true;
			this->Time->Width = 85;
			// 
			// Priority
			// 
			this->Priority->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::None;
			dataGridViewCellStyle10->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter;
			this->Priority->DefaultCellStyle = dataGridViewCellStyle10;
			this->Priority->HeaderText = L"Priority";
			this->Priority->Name = L"Priority";
			this->Priority->ReadOnly = true;
			this->Priority->Width = 50;
			// 
			// Taskname
			// 
			this->Taskname->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::Fill;
			this->Taskname->HeaderText = L"Task";
			this->Taskname->Name = L"Taskname";
			this->Taskname->ReadOnly = true;
			// 
			// Status
			// 
			this->Status->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::None;
			dataGridViewCellStyle11->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter;
			this->Status->DefaultCellStyle = dataGridViewCellStyle11;
			this->Status->HeaderText = L"Status";
			this->Status->Name = L"Status";
			this->Status->ReadOnly = true;
			this->Status->Width = 40;
			// 
			// exitButton
			// 
			this->exitButton->BackColor = System::Drawing::SystemColors::Window;
			this->exitButton->Location = System::Drawing::Point(1264, 12);
			this->exitButton->Margin = System::Windows::Forms::Padding(4, 4, 4, 4);
			this->exitButton->Name = L"exitButton";
			this->exitButton->Size = System::Drawing::Size(96, 42);
			this->exitButton->TabIndex = 10;
			this->exitButton->Text = L"X";
			this->exitButton->UseVisualStyleBackColor = false;
			this->exitButton->Click += gcnew System::EventHandler(this, &LazyManCalendar::exitButton_Click);
			// 
			// warningBar
			// 
			this->warningBar->BackColor = System::Drawing::SystemColors::Window;
			this->warningBar->BorderStyle = System::Windows::Forms::BorderStyle::None;
			this->warningBar->Cursor = System::Windows::Forms::Cursors::Arrow;
			this->warningBar->Location = System::Drawing::Point(556, 388);
			this->warningBar->Margin = System::Windows::Forms::Padding(6, 6, 6, 6);
			this->warningBar->Multiline = true;
			this->warningBar->Name = L"warningBar";
			this->warningBar->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
			this->warningBar->Size = System::Drawing::Size(340, 38);
			this->warningBar->TabIndex = 5;
			this->warningBar->TabStop = false;
			this->warningBar->Text = L"Warnings will be displayed here";
			// 
			// labelLazyManCalendar
			// 
			this->labelLazyManCalendar->AutoSize = true;
			this->labelLazyManCalendar->Location = System::Drawing::Point(94, 29);
			this->labelLazyManCalendar->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
			this->labelLazyManCalendar->Name = L"labelLazyManCalendar";
			this->labelLazyManCalendar->Size = System::Drawing::Size(188, 26);
			this->labelLazyManCalendar->TabIndex = 14;
			this->labelLazyManCalendar->Text = L"LazyManCalendar";
			// 
			// minimiseButton
			// 
			this->minimiseButton->BackColor = System::Drawing::SystemColors::Window;
			this->minimiseButton->ForeColor = System::Drawing::SystemColors::ControlText;
			this->minimiseButton->Location = System::Drawing::Point(1160, 12);
			this->minimiseButton->Margin = System::Windows::Forms::Padding(4, 4, 4, 4);
			this->minimiseButton->Name = L"minimiseButton";
			this->minimiseButton->Size = System::Drawing::Size(96, 42);
			this->minimiseButton->TabIndex = 10;
			this->minimiseButton->Text = L"__";
			this->minimiseButton->UseVisualStyleBackColor = false;
			this->minimiseButton->Click += gcnew System::EventHandler(this, &LazyManCalendar::minimiseButton_Click);
			// 
			// displayDateTime
			// 
			this->displayDateTime->AutoSize = true;
			this->displayDateTime->Location = System::Drawing::Point(304, 29);
			this->displayDateTime->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
			this->displayDateTime->Name = L"displayDateTime";
			this->displayDateTime->Size = System::Drawing::Size(174, 26);
			this->displayDateTime->TabIndex = 15;
			this->displayDateTime->Text = L"displayDateTime";
			// 
			// timer
			// 
			this->timer->Tick += gcnew System::EventHandler(this, &LazyManCalendar::timer_Tick);
			// 
			// statusBar
			// 
			this->statusBar->BackColor = System::Drawing::SystemColors::ControlDarkDark;
			this->statusBar->BorderStyle = System::Windows::Forms::BorderStyle::None;
			this->statusBar->Cursor = System::Windows::Forms::Cursors::Arrow;
			this->statusBar->ForeColor = System::Drawing::SystemColors::Window;
			this->statusBar->Location = System::Drawing::Point(58, 17);
			this->statusBar->Margin = System::Windows::Forms::Padding(6, 6, 6, 6);
			this->statusBar->Name = L"statusBar";
			this->statusBar->Size = System::Drawing::Size(1308, 24);
			this->statusBar->TabIndex = 4;
			this->statusBar->TabStop = false;
			this->statusBar->Text = L"Status will be displayed here\r\n";
			this->statusBar->Enter += gcnew System::EventHandler(this, &LazyManCalendar::statusBar_Enter);
			// 
			// iconPictureBox
			// 
			this->iconPictureBox->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"iconPictureBox.Image")));
			this->iconPictureBox->Location = System::Drawing::Point(12, 12);
			this->iconPictureBox->Margin = System::Windows::Forms::Padding(4, 4, 4, 4);
			this->iconPictureBox->Name = L"iconPictureBox";
			this->iconPictureBox->Size = System::Drawing::Size(76, 67);
			this->iconPictureBox->TabIndex = 16;
			this->iconPictureBox->TabStop = false;
			// 
			// monthCalendar
			// 
			this->monthCalendar->Location = System::Drawing::Point(910, 88);
			this->monthCalendar->Margin = System::Windows::Forms::Padding(8, 10, 8, 10);
			this->monthCalendar->Name = L"monthCalendar";
			this->monthCalendar->TabIndex = 17;
			this->monthCalendar->DateSelected += gcnew System::Windows::Forms::DateRangeEventHandler(this, &LazyManCalendar::monthCalendar_DateSelected);
			// 
			// statusPanel
			// 
			this->statusPanel->BackColor = System::Drawing::SystemColors::ControlDarkDark;
			this->statusPanel->Controls->Add(this->crossPictureBox);
			this->statusPanel->Controls->Add(this->tickPictureBox);
			this->statusPanel->Controls->Add(this->statusBar);
			this->statusPanel->Dock = System::Windows::Forms::DockStyle::Bottom;
			this->statusPanel->Location = System::Drawing::Point(0, 480);
			this->statusPanel->Margin = System::Windows::Forms::Padding(6, 6, 6, 6);
			this->statusPanel->Name = L"statusPanel";
			this->statusPanel->Size = System::Drawing::Size(1380, 62);
			this->statusPanel->TabIndex = 18;
			// 
			// crossPictureBox
			// 
			this->crossPictureBox->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"crossPictureBox.Image")));
			this->crossPictureBox->Location = System::Drawing::Point(4, 8);
			this->crossPictureBox->Margin = System::Windows::Forms::Padding(4, 4, 4, 4);
			this->crossPictureBox->Name = L"crossPictureBox";
			this->crossPictureBox->Size = System::Drawing::Size(50, 48);
			this->crossPictureBox->TabIndex = 6;
			this->crossPictureBox->TabStop = false;
			// 
			// tickPictureBox
			// 
			this->tickPictureBox->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"tickPictureBox.Image")));
			this->tickPictureBox->Location = System::Drawing::Point(4, 8);
			this->tickPictureBox->Margin = System::Windows::Forms::Padding(4, 4, 4, 4);
			this->tickPictureBox->Name = L"tickPictureBox";
			this->tickPictureBox->Size = System::Drawing::Size(50, 48);
			this->tickPictureBox->TabIndex = 5;
			this->tickPictureBox->TabStop = false;
			// 
			// LazyManCalendar
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(12, 25);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->BackColor = System::Drawing::SystemColors::Window;
			this->ClientSize = System::Drawing::Size(1380, 542);
			this->Controls->Add(this->monthCalendar);
			this->Controls->Add(this->iconPictureBox);
			this->Controls->Add(this->table);
			this->Controls->Add(this->warningBar);
			this->Controls->Add(this->displayDateTime);
			this->Controls->Add(this->minimiseButton);
			this->Controls->Add(this->labelLazyManCalendar);
			this->Controls->Add(this->exitButton);
			this->Controls->Add(this->lastCommandBar);
			this->Controls->Add(this->helpButton);
			this->Controls->Add(this->inputBox);
			this->Controls->Add(this->statusPanel);
			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::None;
			this->Icon = (cli::safe_cast<System::Drawing::Icon^  >(resources->GetObject(L"$this.Icon")));
			this->Margin = System::Windows::Forms::Padding(6, 6, 6, 6);
			this->Name = L"LazyManCalendar";
			this->Text = L"LazyManCalendar";
			this->Load += gcnew System::EventHandler(this, &LazyManCalendar::LazyManCalendar_Load);
			this->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &LazyManCalendar::LazyManCalendar_MouseDown);
			this->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &LazyManCalendar::LazyManCalendar_MouseMove);
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->table))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->iconPictureBox))->EndInit();
			this->statusPanel->ResumeLayout(false);
			this->statusPanel->PerformLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->crossPictureBox))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->tickPictureBox))->EndInit();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion

// show reminders when user opens application
private: System::Void LazyManCalendar_Load(System::Object^  sender, System::EventArgs^  e) {
			 tickPictureBox->Hide();
			 crossPictureBox->Hide();

			 schedule->start(REMINDER);
			 vector <string> taskNames = schedule->getForUITaskName();
			 vector <string> deadlines = schedule->getForUIDeadline();
			 vector <string> prioritys = schedule->getForUIPriority();
			 vector <string> times = schedule->getForUITime();
			 vector <string> statuses = schedule->getForUIStatus();

			 getTableRows();
			
			 for(unsigned int i = 0; i < taskNames.size(); i++) {
				table->Rows[i]->Cells[0]->Value = i+1;
				table->Rows[i]->Cells[1]->Value = gcnew String(deadlines[i].c_str());
				table->Rows[i]->Cells[2]->Value = gcnew String(times[i].c_str());
				table->Rows[i]->Cells[3]->Value = gcnew String(prioritys[i].c_str());
				table->Rows[i]->Cells[4]->Value = gcnew String(taskNames[i].c_str());
				table->Rows[i]->Cells[5]->Value = gcnew String(statuses[i].c_str());
				if(statuses[i] == CMI) {
					table->Rows[i]->DefaultCellStyle->BackColor = Color::LightSalmon;
				 }
			 }
			 table->ClearSelection();
			 updateCalendar();
			 autoCompleteText();
		 }

//detect input after loading 
private: System::Void inputBox_PreviewKeyDown(System::Object^  sender, System::Windows::Forms::PreviewKeyDownEventArgs^  e) {
			 //able to scroll the scollbar by pressing up or pageup
			 if(e->KeyCode == Keys::Up || e->KeyCode == Keys::PageUp) {
				try {
					table->FirstDisplayedScrollingRowIndex -= 1;
				}
				catch(...) {
					return;
				}
			 }
			 //able to scroll the scollbar by pressing down or pagedown
			 if(e->KeyCode == Keys::Down || e->KeyCode == Keys::PageDown) {
				try {
					table->FirstDisplayedScrollingRowIndex += 1;
				}
				catch(...) {
					return;
				}
			 }
			 
			 if(e->KeyCode == Keys::Escape) {
				 escapeFunction();
			 }
			 
			 if(e->KeyCode == Keys::F1 || e->KeyCode == Keys::F2 || e->KeyCode == Keys::F3 || e->KeyCode == Keys::F4 || e->KeyCode == Keys::Enter 
				 || (e->KeyCode == Keys::Z && e->Modifiers == Keys::Control) || (e->KeyCode == Keys::Y && e->Modifiers == Keys::Control)) {
					 
					 String^ input;
					 String^ lastCommand;
					 string userInput;
					 
					 if(e->KeyCode == Keys::F1) {
						 lastCommand = gcnew String(LASTCMDHELP.c_str());
						 helpFunction();
						 return;
					 
					 } else if (e->KeyCode == Keys::F2) {
						 userInput = REMINDER;
						 lastCommand = gcnew String(LASTCMDREMINDER.c_str());
					 
					 } else if (e->KeyCode == Keys::F3) {
						 userInput = DISPLAY;
						 lastCommand = gcnew String(LASTCMDDISPLAY.c_str());
					 
					 } else if (e->KeyCode == Keys::F4) {
						 input = (inputBox->Text);
						 userInput = SEARCHES;
						 userInput += marshal_as<std::string>(input);
						 lastCommand = gcnew String(LASTCMDSEARCH.c_str());
						 lastCommand += input;
					
					 } else if(e->KeyCode == Keys::Z && e->Modifiers == Keys::Control) {
						 userInput = UNDO;
						 lastCommand = gcnew String(LASTCMDUNDO.c_str());
					 
					 } else if(e->KeyCode == Keys::Y && e->Modifiers == Keys::Control) { 
						 userInput = REDO;
						 lastCommand = gcnew String(LASTCMDREDO.c_str());
					 
					 } else if(e->KeyCode == Keys::Enter) {
						 input = (inputBox->Text);
						 lastCommand = gcnew String(LASTCMD.c_str());
						 lastCommand += input;
						 userInput = marshal_as<std::string>(input);
						 
						 if(userInput == EXIT) {
							 exit(0);
						 }
					 }
					 
					 lastCommandBar->Text = lastCommand;
					 
					 inputBox->Text = gcnew String(EMPTY.c_str());
					 statusBar->Text = gcnew String(EMPTY.c_str());
					 
					 schedule->start(userInput);
					 
					 vector <string> taskNames = schedule->getForUITaskName();
					 vector <string> deadlines = schedule->getForUIDeadline();
					 vector <string> prioritys = schedule->getForUIPriority();
					 vector <string> times = schedule->getForUITime();
					 vector <string> statuses = schedule->getForUIStatus();
					 
					 getTableRows();
					 
					 for(unsigned int i = 0; i < taskNames.size(); i++) {
						 table->Rows[i]->Cells[0]->Value = i+1;
						 table->Rows[i]->Cells[1]->Value = gcnew String(deadlines[i].c_str());
						 table->Rows[i]->Cells[2]->Value = gcnew String(times[i].c_str());
						 table->Rows[i]->Cells[3]->Value = gcnew String(prioritys[i].c_str());
						 table->Rows[i]->Cells[4]->Value = gcnew String(taskNames[i].c_str());
						 table->Rows[i]->Cells[5]->Value = gcnew String(statuses[i].c_str());
						 if(statuses[i] == CMI) {
							 table->Rows[i]->DefaultCellStyle->BackColor = Color::LightSalmon;
						 } else if(statuses[i] == DONE) {
							 table->Rows[i]->DefaultCellStyle->BackColor = Color::LightGreen;
						 } else if(statuses[i] == ARCHIVE) {
							 table->Rows[i]->DefaultCellStyle->BackColor = Color::DarkGoldenrod;
						 }
					 }
					 
					 displayFeedbackTickOrCross();
					 displayWarning();
					 
					 table->ClearSelection();
					 
					 if(input != gcnew String(EMPTY.c_str())) {
						 updateCalendar();
					 }
					 
					 autoCompleteText();	
			 }
}

//set bold dates on calendar
private: void boldDatesForCalendar() {
			 vector <string> deadlines = schedule->getForUICalendar();
			 
			 int day = 0;
			 int month = 0;
			 int year = 0;
			 
			 DateTime boldDates;
			 
			 for(unsigned int i = 0; i < deadlines.size(); i++) {
				 if(deadlines[i] != EMPTY) {
				 string data = deadlines[i];
				 istringstream readString(data);
				 readString >> day >> month >> year;
				
				 // day is 1-31
				 // month is 1-12
				 // year is in 4 digit format, e.g. 2014
				 assert(day != 0);
				 assert(month != 0);
				 assert(year != 0);
				 
				 boldDates = DateTime (year, month, day);
				 monthCalendar->AddBoldedDate(boldDates);
				 }
			 }
		 }

//update bolddays to calendar on GUI
private: void updateCalendar() {
			 //remove dates that are bolded upon deletion of task
			 monthCalendar->RemoveAllBoldedDates();
			 //set dates to bolded
			 boldDatesForCalendar();
			 monthCalendar->UpdateBoldedDates();
		 }
		
//click or drag the calendar to search task
private: System::Void monthCalendar_DateSelected(System::Object^  sender, System::Windows::Forms::DateRangeEventArgs^  e) {
			 String^ DATE = (monthCalendar->SelectionStart).ToShortDateString();
			 string date = marshal_as<std::string>(DATE);
			 int find1 = date.find(SLASH);
			 int find2 = date.find(SLASH,find1+1);
			 date = date.substr(0,find2);
			 DATE = gcnew String(date.c_str());

			 String^ DATEEND = (monthCalendar->SelectionEnd).ToShortDateString();
			 date = marshal_as<std::string>(DATEEND);
			 find1 = date.find(SLASH);
			 find2 = date.find(SLASH,find1+1);
			 date = date.substr(0,find2);
			 DATEEND = gcnew String(date.c_str());

			 if(DATE != DATEEND) {
				 DATE += gcnew String(DASH.c_str()) + DATEEND;
			 }

			 inputBox->Focus();
			 SendKeys::Send("search ");
			 SendKeys::Send(DATE);
			 SendKeys::Send("{ENTER}");
		 }

//suggest to user autocomplete with tasknames
private: void autoCompleteText() {	 
			 vector <string> taskNames = schedule->getForUITaskName();

			 inputBox->AutoCompleteMode = AutoCompleteMode::SuggestAppend;
			 inputBox->AutoCompleteSource = AutoCompleteSource::CustomSource;
			 
			 if(taskNames.size() != 0) {
				 for(unsigned int i = 0; i < taskNames.size(); i++) {
					 try{
						 inputBox->AutoCompleteCustomSource->Add(gcnew String(taskNames[i].c_str()));
					 } catch(...) {
						 return;
					 }
				 }
			 }
		 }

//display to user a helpfunction by pressing F1 or click on button
private: void helpFunction() {
			 vector <string> help = schedule->getForUIHelp();
			 String^ Help;
			 
			 for(vector<string>::iterator iter = help.begin(); iter != help.end(); iter ++) {
				 Help += gcnew String((*iter).c_str());
			 }
			 
			 MessageBox::Show(Help, "LazyManCalendar", MessageBoxButtons::OK, MessageBoxIcon::None);
		 }

//press esc key to clear input box
private: void escapeFunction() {
			 inputBox->Text = gcnew String(EMPTY.c_str());
			 return;
		}

//get the number of rows from logic and print out the number of rows needed
private: void getTableRows() {
			 vector <string> taskNames = schedule->getForUITaskName();
			 
			 table->Rows->Clear();
			 
			 for(unsigned int i = table->RowCount; i < taskNames.size(); i++) {
					table->Rows->Add();
			 }
		 }

// showing tick/cross as well as user feedback simultaneously
private: void displayFeedbackTickOrCross() {
			 string cFeedback = schedule->getForUIFeedback();
			 
			 if(cFeedback != EMPTY) {
				 String ^ feedback = gcnew String(cFeedback.c_str());
				 statusBar->Text = feedback;
				 
				 bool tickOrCross = schedule->getTickOrCross();
				 
				 if(tickOrCross) {
					 crossPictureBox->Hide();
					 tickPictureBox->Visible = true;
				 } else {
					 tickPictureBox->Hide();	
					 crossPictureBox->Visible = true;
				 }
			 // if no feedback, shouldn't show anything
			 } else {	
				 crossPictureBox->Hide();
				 tickPictureBox->Hide();
			 }
		 }

//display warnings and show to user
private: void displayWarning() {
			 String ^ warning = gcnew String((schedule->getForUIWarning()).c_str());
			 warningBar->Text = warning;
		 }

// displayTimeDate to run time dynamically
private: System::Void timer_Tick(System::Object^  sender, System::EventArgs^  e) {
			 DateTime dateTime = DateTime::Now;
			 this->displayDateTime->Text = dateTime.ToString("dddd") + " " + dateTime.ToString();
		 }

//Create buttons on the form
private: System::Void exitButton_Click(System::Object^  sender, System::EventArgs^  e) {
			 exit(0);
		 }
private: System::Void minimiseButton_Click(System::Object^  sender, System::EventArgs^  e) {
			 WindowState = FormWindowState::Minimized;
		 }
private: System::Void helpButton_Click(System::Object^  sender, System::EventArgs^  e) {
			 helpFunction();
		 }

//Customize form border
private: System::Void LazyManCalendar_MouseDown(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) {
			 xOffSet = Control::MousePosition.X - Location.X;
			 yOffSet = Control::MousePosition.Y - Location.Y;
		 }
private: System::Void LazyManCalendar_MouseMove(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) {
			 if(e->Button == Windows::Forms::MouseButtons::Left) {
				 mouseOffSet = Control::MousePosition;
				 mouseOffSet.X -= (xOffSet);
				 mouseOffSet.Y -= (yOffSet);
				 Location = mouseOffSet;
			 }
		 }

// focus all to input box
private: System::Void helpButton_Enter(System::Object^  sender, System::EventArgs^  e) {
			 inputBox->Focus();
		 }
private: System::Void statusBar_Enter(System::Object^  sender, System::EventArgs^  e) {
			 inputBox->Focus();
		 }
private: System::Void lastCommandBar_Enter(System::Object^  sender, System::EventArgs^  e) {
			 inputBox->Focus();
		 }
private: System::Void table_PreviewKeyDown(System::Object^  sender, System::Windows::Forms::PreviewKeyDownEventArgs^  e) {
			 inputBox->Focus();
		 }
};
}
